import axios from "axios"
// import qs from "qs"
const baseURL = "http://lmx.free.idcfengye.com"
// const baseURL = "192.168.2.109:8089"
// const baseURL = "/"
// const baseURL = "http://lsdroot.free.idcfengye.com"
// const baseURL = "http://192.168.2.109:8089"
// const baseURL = "http://zone3743.free.idcfengye.com/"
// const baseURL = "http://backstage123.free.idcfengye.com/"
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';

const request = axios.create({
    baseURL,
    timeout:5000,
})

// {username:"zhangsan"}  ---  username=zhagnsan

// 请求 拦截器 ---

// 客户端发请求  --- 请求拦截器  ---- 服务器   xxx-www-form-urlencode 
// username:zhangsan   -- username:lisi  ---
//                     token   ----
request.interceptors.request.use(config => {
      
    const token = localStorage.token
    if(token){
        config.headers.accessToken = token;
    }
      
    // config.params = {...config.params,accesstoken:token}
    // config.data = {...config.data,accesstoken:token}
    if(token)
    config.headers.accessToken = token;
    //必须得有
    // config.data = qs.stringify({...config.data})
    // config.data = {...config.data,message:{"uid":1,"mtext":"上帝啊时间","faid":0,"pid":1,"label":"推荐"}}
    return config
},err => {
    //请求出错的处理函数
    return Promise.reject(err)
})


export default request
